package com.guigu.health.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.guigu.health.dao.OrderCheckItemDetailsMapper;
import com.guigu.health.dao.OrderMapper;
import com.guigu.health.dao.OrderSetMemalDetailsMapper;
import com.guigu.health.pojo.Order;
import com.guigu.health.pojo.OrderCheckItemDetails;
import com.guigu.health.pojo.OrderExample;
import com.guigu.health.pojo.OrderSetMemalDetails;
import com.guigu.health.service.OrderDetails;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName:OrderDetailsImpl
 * @Description:
 * @Author:longtao
 * @Date:2021/4/11
 * @Version:1.0
 */
@Service("OrderDetails2")
public class OrderDetailsImpl implements OrderDetails {

    private OrderSetMemalDetailsMapper orderSetMemalDetailsMapper;

    @Autowired
    @Qualifier("orderSetMemalDetailsMapper")

    public void setOrderSetMemalDetailsMapper(OrderSetMemalDetailsMapper orderSetMemalDetailsMapper) {
        this.orderSetMemalDetailsMapper = orderSetMemalDetailsMapper;
    }

    @Autowired
    @Qualifier("orderCheckItemDetailsMapper")
    private OrderCheckItemDetailsMapper orderCheckItemDetailsMapper;

    public void setOrderCheckItemDetailsMapper(OrderCheckItemDetailsMapper orderCheckItemDetailsMapper) {
        this.orderCheckItemDetailsMapper = orderCheckItemDetailsMapper;
    }

    private OrderMapper orderMapper;

    @Autowired
    @Qualifier("orderMapper")
    public void setOrderMapper(OrderMapper orderMapper) {
        this.orderMapper = orderMapper;
    }

    @Override
    public PageInfo<OrderSetMemalDetails> queryAllSetMemal(String name, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
      List<OrderSetMemalDetails> list=orderSetMemalDetailsMapper.queryAll("%"+name+"%");
      PageInfo<OrderSetMemalDetails> pageInfo=new PageInfo<OrderSetMemalDetails>(list);
        return pageInfo;
    }

    @Override
    public PageInfo<OrderCheckItemDetails> queryAllCheckItem(String name, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<OrderCheckItemDetails> list=orderCheckItemDetailsMapper.queryAll("%"+name+"%");
        PageInfo<OrderCheckItemDetails> pageInfo=new PageInfo<OrderCheckItemDetails>(list);
        return pageInfo;
    }

    @Override
    public boolean deleteDetails(Integer id) {
        boolean flag=false;
        int i = orderCheckItemDetailsMapper.deleteOrder(id);
        if (i>0){
            flag=true;
        }
        return flag;
    }

    @Override
    public boolean updateOrder(Order order, OrderExample example) {
        boolean flag=false;
        int i = orderMapper.updateByExampleSelective(order, example);
        if (i>0){
            flag=true;
        }
        return flag;
    }
}
